#include <iostream>
#include<list>
#include<string>
using namespace std;

int main()
{
    list<int> l;
    string s;
    int sum = 0;

    cin >> sum;
    cin>>s;
    for (int i = 1; i <= sum; i++)
        l.push_back(i);

    auto begin = l.begin();
    auto point = l.begin();
    for (auto e : s)
    {
        if (e == 'U')
        {
            if (*point == 1)
            {
                int k = 4;
                while (k--)
                    begin--;
            }
            else if (begin == point)
            {
                begin--;
                point--;
            }
            else
                begin--;
        }
        else
        {
            if (*point == sum)
            {
                begin = l.begin();
            }
            else if (*point == *begin + 3)
            {
                begin++;
                point++;
            }
            else
                begin++;
        }
    }
    int k = 4;
    while (k--)
    {
        cout << *begin << " ";
        begin++;
    }
    cout << endl << *point;

}